package com.ims.core.doc.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ims.common.annotation.Log;
import com.ims.common.core.controller.BaseController;
import com.ims.common.core.domain.AjaxResult;
import com.ims.common.enums.BusinessType;
import com.ims.core.doc.domain.TInCollectInvoice;
import com.ims.core.doc.service.ITInCollectInvoiceService;
import com.ims.common.utils.poi.ExcelUtil;
import com.ims.common.core.page.TableDataInfo;

/**
 * 采集增值税发票结果Controller
 *
 * @author IMS
 * @date 2024-11-10
 */
@RestController
@RequestMapping("/system/invoice")
public class TInCollectInvoiceController extends BaseController
{
    @Autowired
    private ITInCollectInvoiceService tInCollectInvoiceService;

    /**
     * 查询采集增值税发票结果列表
     */
    @PreAuthorize("@ss.hasPermi('system:invoice:list')")
    @GetMapping("/list")
    public TableDataInfo list(TInCollectInvoice tInCollectInvoice)
    {
        startPage();
        List<TInCollectInvoice> list = tInCollectInvoiceService.selectTInCollectInvoiceList(tInCollectInvoice);
        return getDataTable(list);
    }

    /**
     * 导出采集增值税发票结果列表
     */
    @PreAuthorize("@ss.hasPermi('system:invoice:export')")
    @Log(title = "采集增值税发票结果", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TInCollectInvoice tInCollectInvoice)
    {
        List<TInCollectInvoice> list = tInCollectInvoiceService.selectTInCollectInvoiceList(tInCollectInvoice);
        ExcelUtil<TInCollectInvoice> util = new ExcelUtil<TInCollectInvoice>(TInCollectInvoice.class);
        util.exportExcel(response, list, "采集增值税发票结果数据");
    }

    /**
     * 获取采集增值税发票结果详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:invoice:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tInCollectInvoiceService.selectTInCollectInvoiceById(id));
    }

    /**
     * 新增采集增值税发票结果
     */
    @PreAuthorize("@ss.hasPermi('system:invoice:add')")
    @Log(title = "采集增值税发票结果", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TInCollectInvoice tInCollectInvoice)
    {
        return toAjax(tInCollectInvoiceService.insertTInCollectInvoice(tInCollectInvoice));
    }

    /**
     * 修改采集增值税发票结果
     */
    @PreAuthorize("@ss.hasPermi('system:invoice:edit')")
    @Log(title = "采集增值税发票结果", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TInCollectInvoice tInCollectInvoice)
    {
        return toAjax(tInCollectInvoiceService.updateTInCollectInvoice(tInCollectInvoice));
    }

    /**
     * 删除采集增值税发票结果
     */
    @PreAuthorize("@ss.hasPermi('system:invoice:remove')")
    @Log(title = "采集增值税发票结果", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tInCollectInvoiceService.deleteTInCollectInvoiceByIds(ids));
    }
}
